perm filename A45[106,RWF] blob
sn#790299 filedate 1985-03-11 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 _Example_
C00004 ENDMK
C⊗;
_Example_
I have read a real number X, and I want to print asterisks across the
page as close as possible to the integer multiples of X inches (10X columns).
The ideal column for the i↑th asterisk, if we count columns from zero, is
10*I*X, and the closest we can come is ROUND(10*I*X). By keeping track
of which column the last asterisk appeared in, we can determine how many
spaces to print between. If the last column is numbered 131, we can do
this so long as ROUND(10*I*X)≤131.
BEGIN
READ(X);
IF X<0.1 THEN X:=0.1; (* only one character per column *)
WRITE('X');
LASTC:= O;
I:= 1;
NEXTC:= ROUND(10*I*X);
WHILE NEXT C <= 131 DO
BEGIN
FOR I:= 1 TO NEXTC - LASTC -1 DO
WRITE(' ')
WRITE('*');
LASTC:= NEXTC;
NEXTC:= ROUND(10*I*X*)
END
END.